#!/bin/bash
echo "hi, start deploy....."
git pull
echo "-------------------- shutdown running server start -------------------"
sh /www/server/tomcat/bin/shutdown.sh
sh /opt/taskCenter/bin/stop.sh
sh /root/center/bin/stop.sh
echo "--------------------- shutdown running server end --------------------"


echo "------------------------ compile code start --------------------------"
mvn clean install
echo "------------------------ compile code end ----------------------------"


echo "------------------------ compile code start --------------------------"
rm -rf /opt/taskCenter/lib/mfoyou-agent-*.jar
cp /root/.m2/repository/com/mfoyou/server/mfoyou-agent-common/0.0.1-SNAPSHOT/mfoyou-agent-common-0.0.1-SNAPSHOT.jar /opt/taskCenter/lib/
cp /root/.m2/repository/com/mfoyou/server/mfoyou-agent-taobao/0.0.1-SNAPSHOT/mfoyou-agent-taobao-0.0.1-SNAPSHOT.jar /opt/taskCenter/lib/
cp /root/.m2/repository/com/mfoyou/server/mfoyou-agent-task/0.0.1-SNAPSHOT/mfoyou-agent-task-0.0.1-SNAPSHOT.jar /opt/taskCenter/lib/
cp /root/.m2/repository/com/mfoyou/server/mfoyou-agent-utils/0.0.1-SNAPSHOT/mfoyou-agent-utils-0.0.1-SNAPSHOT.jar /opt/taskCenter/lib/


rm -rf /root/center/lib/mfoyou-agent-*.jar
cp /root/.m2/repository/com/mfoyou/server/mfoyou-agent-center/0.0.1-SNAPSHOT/mfoyou-agent-center-0.0.1-SNAPSHOT.jar /root/center/lib/
cp /root/.m2/repository/com/mfoyou/server/mfoyou-agent-common/0.0.1-SNAPSHOT/mfoyou-agent-common-0.0.1-SNAPSHOT.jar /root/center/lib/
cp /root/.m2/repository/com/mfoyou/server/mfoyou-agent-utils/0.0.1-SNAPSHOT/mfoyou-agent-utils-0.0.1-SNAPSHOT.jar /root/center/lib/

rm -rf /www/server/tomcat/webapps/*
cp /root/.m2/repository/com/mfoyou/server/mfoyou-agent-web/0.0.1-SNAPSHOT/mfoyou-agent-web-0.0.1-SNAPSHOT.war /www/server/tomcat/webapps/ROOT.war
echo "------------------------ compile code end ----------------------------"

echo "-------------------- startup running server start --------------------"
echo "clean tomcat log"
rm -rf /www/server/tomcat/logs/*.log
sh /www/server/tomcat/bin/startup.sh
sh /opt/taskCenter/bin/start.sh
sh /root/center/bin/start.sh
echo "-------------------- startup running server end  ---------------------"

echo "deploy finish!!!!!!!"
